package com.code.AZPlan.service.mapper;

import com.code.AZPlan.model.bo.*;
import com.code.AZPlan.model.po.*;
import com.code.commons.dao.CrudMapper;
import com.code.user.model.bo.UserCoinBalanceBO;
import com.code.user.model.bo.UserRecommenderBO;
import com.code.user.model.po.UserCoinBalance;
import com.code.user.model.po.UserRecommender;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * AZ计划静态收益持久层映射接口
 *
 * @author tangyifei
 * @since 2019年12月20日17:50:27
 */
@Repository
public interface AZPlanStaticIncomeMapper extends CrudMapper<AZPlanBalance> {

    AZPlanBalance getAZPlanBalanceByUserId(@Param("userId") String userId);

    List<UserRecommender> getUserRecommenderByRecommenderUserId(@Param("userId") String userId);

    List<UserRecommenderBO> getRecommendsByUserIds(@Param("userIds") List<String> userIds, @Param("entryMoneyState") Integer entryMoneyState);

    List<UserRelativeVersionBO> getUserRelativeVersionBOList(List<UserRecommender> userRecommender);

    UserRelativeVersionBO getUserRelativeVersionBO(@Param("userId") String userId);

    List<AZPlanBalance> getUserOrePoolVersionList();

    int addUSDTCoinBalance(@Param("userId") String userId, @Param("coinBalance") BigDecimal coinBalance,
                           @Param("coinType") String coinType, @Param("version") Integer version,
                           @Param("updateTime") Date updateTime);

//    int updateOrePool(@Param("userId") String userId, @Param("orePool") BigDecimal orePool,
//                      @Param("azPlanStatus") Integer azPlanStatus, @Param("version") Integer version,
//                      @Param("updateTime") Date updateTime);

    List<IncomeFlow> getIncomes(@Param("userId") String userId);

    List<IncomeBO> getIncomeFlows(@Param("userId") String userId);

    List<ExchangeFlow> getExchanges(@Param("userId") String userId, @Param("coinType") String coinType);

    List<EntryMoneyFlow> getEntryMoneyFlows(@Param("userId") String userId, @Param("coinType") String coinType);

    List<WithdrawOrder> getWithdrawList(WithdrawBO withdrawBO);

    WithdrawOrder getWithdrawOrder(@Param("id") String id);

    BigDecimal getOrePool(@Param("userId") String userId);

    Integer getUserCoinBalanceVersion(@Param("userId") String userId, @Param("coinType") String coinType);

    BigDecimal getUserCoinBalance(@Param("userId") String userId, @Param("coinType") String coinType, @Param("coinAddress") String coinAddress);

    AZPlanWallet getAZPlanWallet(@Param("userId") String userId, @Param("coinType") String coinType);

    List<TransferInOutFlow> getTransferInOutFlowList(@Param("userId") String userId, @Param("coinType") String coinType, @Param("flowType") Integer flowType);

    List<TransferInOutFlow> getInSiteTransferInOutFlowList(WithdrawBO withdrawBO);

    BigDecimal getTotalStaticIncomeAmount(@Param("userId") String userId);

    BigDecimal getTotalExchangeAmount(@Param("userId") String userId);

    BigDecimal getTotalExchangeAmountForOtherCoin(@Param("userId") String userId, @Param("coinType") String coinType);

//    BigDecimal getTotalBTCExchangeAmount(@Param("userId") String userId, @Param("coinType") String coinType);

    BigDecimal getTotalDynamicIncomeAmount(@Param("userId") String userId);

    BigDecimal getTotalWalletAmount(@Param("userId") String userId, @Param("coinType") String coinType);

    BigDecimal getFrozenAmount(@Param("userId") String userId, @Param("coinType") String coinType);

    BigDecimal getFrozenFee(@Param("userId") String userId, @Param("coinType") String coinType);

    MoneyTransferRecord getMoneyTransferByUserIdAndCoinType(@Param("userId") String userId, @Param("coinType") String coinType, @Param("transferType") Integer transferType);

    int reduceUserCoinBalance(UserCoinBalance userCoinBalance);

    int addUserCoinBalance(UserCoinBalance userCoinBalance);

    int addAZPlanWalletAmount(AZPlanWallet azPlanWallet);

    int reduceAZPlanWalletAmount(AZPlanWallet azPlanWallet);

    int insertTransferInOutFlow(TransferInOutFlow transferInOutFlow);

    int insertRechargeTran(RechargeTran rechargeTran);

    String getUserPhoneByUserId(@Param("userId") String userId);

    void insertExchangeFlow(ExchangeFlow exchangeFlow);

    int insertWithdrawOrder(WithdrawOrder withdrawOrder);

    int updateMoneyTransferRecord(MoneyTransferRecord moneyTransferRecord);

    void updateAZPlanStatus(@Param("userId") String userId, @Param("azPlanStatus") Integer azPlanStatus);

    void updateAZPlanDynamicTotalIncome(@Param("userId") String userId, @Param("totalDynamicIncome") BigDecimal totalDynamicIncome, @Param("version") Integer version);

    int updateAZPlanStaticTotalIncome(@Param("userId") String userId, @Param("totalStaticIncomeAmount") BigDecimal totalStaticIncomeAmount, @Param("version") Integer version);

    void updateUserRecommender(@Param("recommenderId") String recommenderId, @Param("recommenderUserId") String recommenderUserId,
                               @Param("income") BigDecimal income, @Param("recommenderIncomeHistory") String recommenderIncomeHistory, @Param("updateTime") Date updateTime);

//    void updateAZPlanBalanceUserVipLevel(@Param("userId") String userId, @Param("userVipLevel") String userVipLevel, @Param("updateTime") Date updateTime);

    void patchUpdateAZPlanBalanceUserVipLevelList(List<UserVipBO> userVipBOS);

//    void updateUserLevel(@Param("userId") String userId, @Param("userLevel") String userLevel, @Param("updateTime") Date updateTime);

    void patchUpdateUserLevel(List<UserVipBO> userVipBOS);

    void patchUpdateUserEntryMoneyChannel(List<UserVipBO> userVipBOS);

//    void updateUserAzPlanChannel(@Param("userId") String userId, @Param("lockStatus") Integer lockStatus, @Param("channel") String channel, @Param("updateTime") Date updateTime);

//    Integer getRecommenderIndex(@Param("recommenderId") String recommenderId);

    void insertEntryMoneyFlow(EntryMoneyFlow entryMoneyFlow);

    void updateAZPlanBalanceByUserId(AZPlanBalance aZPlanBalance);

    void reduceMoneyTransferAmount(MoneyTransferRecord moneyTransferRecord);

    int updateWithdrawOrder(WithdrawOrder withdrawOrder);

    int getAZPlanBalanceVersion(@Param("userId") String userId);

//    BigDecimal getBeforeTotalEntryMoney(@Param("userId") String userId, @Param("entryOtherCoinType") String entryOtherCoinType,
//                                        @Param("entryMoneyChannel") Integer entryMoneyChannel);

    List<AZPlanBalance> getAZPlanBalances();

    int updateStaticIncome(AZPlanBalance azPlanBalanceAfter);

    void patchUpdateAZPlanStatus(List<AZPlanBalance> azPlanBalanceStatusList);

//    List<String> getRecommendIds();

    UserCoinBalanceBO getUserCoinBalanceBO(@Param("userId") String userId);

    void insertIncomeFlowList(List<IncomeFlow> incomeFlowList);

    void insertIncomeFlow(IncomeFlow incomeFlow);

    List<WithdrawOrder> getWithdrawOrderList(@Param("userId") String userId, @Param("coinType") String coinType);

    BigDecimal getTotalMoneyTransferAmount(@Param("userId") String userId, @Param("coinType") String coinType, @Param("transferType") Integer transferType);

    int reduceAZPlanBalance(@Param("userId") String userId, @Param("orePool") BigDecimal orePool,
                            @Param("version") Integer version, @Param("updateTime") Date updateTime);

    List<UserRecommender> getUserRecommenderByRecommenderList(@Param("userId") String userId);

    List<UserRecommender> getNotRecommendUserList();

    void resetCurrentRecommenderRewardArr(List<String> userRecommenderId);

//    List<EntryMoneyBO> getAllChildAccountTotalEntryAmount(@Param("parentId") String parentId);

    List<RechargeTran> getDepositList(RechargeTranBO rechargeTranBO);

    List<UserAsset> getUserAssetList(UserAssetBO userAssetBO);

    void updateUserType(@Param("userIds") List<String> userIds, String userType);

    List<EntryMoneyFlow> getEntryMoneyFlowList(EntryMoneyFlowBO entryMoneyFlowBO);

    List<ExchangeFlow> getExchangeFlowList(ExchangeFlowBO exchangeFlowBO);

    List<IncomeFlow> getIncomeFlowList(IncomeStatisticsDailyBO incomeStatisticsDailyBO);

    List<IncomeFlow> getIncomeDetailList(IncomeStatisticsDailyBO incomeStatisticsDailyBO);

    List<Date> getIncomeDateList(IncomeStatisticsDailyBO incomeStatisticsDailyBO);

    UserCoinBalance getCoinBalance(UserCoinBalance userCoinBalance);

    int addAzNotice(AzNotice azNotice);

    int updateAzNotice(AzNotice azNotice);

    int upDownAzNotice(AzNotice azNotice);

    AzNotice getAzNoticeById(@Param("id") String id);

    List<AzNotice> getAzNoticeList(AzNoticeBO azNoticeBO);

    List<AzNotice> getAzNotices();

    int patchUpdateUpDownState(List<AzNotice> updateNoticeList);

    List<AzNotice> getAzNoticeListByNotNullNoticeTitle(AzNoticeBO azNoticeBO);

    List<AzNotice> getAzNoticeListByNotNullEnglishNoticeTitle(AzNoticeBO azNoticeBO);

    List<AzNotice> getAzNoticeListByNotNullKrNoticeTitle(AzNoticeBO azNoticeBO);

    List<AzNotice> getAzNoticeListByNotNullJpNoticeTitle(AzNoticeBO azNoticeBO);

    List<AzNotice> getAzNoticeListByNotNullRaNoticeTitle(AzNoticeBO azNoticeBO);

    List<AzNotice> getAzNoticeListByNotNullHkNoticeTitle(AzNoticeBO azNoticeBO);

}
